import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:mall/constant/app_colors.dart';
import 'package:mall/constant/app_dimens.dart';
import 'package:mall/constant/app_strings.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class LoadingDialog extends StatelessWidget {
  final String title; //提示文本
  final double titleSize; //文本字体大小
  final Color textColor; //文本颜色
  final double indicatorRadius; // 圆形进度的半径

  LoadingDialog({
    this.title = AppStrings.LOADING,
    this.titleSize = AppDimens.DIMENS_13,
    this.textColor = AppColors.C_999999,
    this.indicatorRadius = 22.5,
  });

  Widget build(BuildContext context) {
    return Material(
      type: MaterialType.transparency,
      child: GestureDetector(
        onTap: () => Navigator.pop(context),
        child: Container(
          color: AppColors.C_TRANSPARENT,
          child: Center(
            child: SizedBox(
              height:
                  ScreenUtil().setHeight((AppDimens.DIMENS_20 + (2 * indicatorRadius).toDouble() + titleSize + 22.5)),
              width: ScreenUtil().setHeight(AppDimens.DIMENS_400),
              child: GestureDetector(
                onTap: () {},
                child: Container(
                  decoration: ShapeDecoration(
                    color: AppColors.C_FFFFFF,
                    shape: RoundedRectangleBorder(
                      borderRadius: BorderRadius.all(
                        Radius.circular(AppDimens.DIMENS_10),
                      ),
                    ),
                  ),
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.center,
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: [
                      CupertinoActivityIndicator(
                        animating: true,
                        radius: ScreenUtil().setHeight(indicatorRadius),
                      ),
                      Padding(
                        padding: EdgeInsets.all(10),
                      ),
                      Text(
                        title,
                        style: TextStyle(fontSize: ScreenUtil().setSp(titleSize), color: textColor),
                      )
                    ],
                  ),
                ),
              ),
            ),
          ),
        ),
      ),
    );
  }
}
